package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GxzyfYfxx;
import com.ruoyi.system.service.IGxzyfYfxxService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 药房信息注册Controller
 * 
 * @author GXzyf
 * @date 2022-09-13
 */
@Controller
@RequestMapping("/system/yfxx")
public class GxzyfYfxxController extends BaseController
{
    private String prefix = "system/yfxx";

    @Autowired
    private IGxzyfYfxxService gxzyfYfxxService;

    @RequiresPermissions("system:yfxx:view")
    @GetMapping()
    public String yfxx()
    {
        return prefix + "/yfxx";
    }

    /**
     * 查询药房信息注册列表
     */
    @RequiresPermissions("system:yfxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(GxzyfYfxx gxzyfYfxx)
    {
        startPage();
        List<GxzyfYfxx> list = gxzyfYfxxService.selectGxzyfYfxxList(gxzyfYfxx);
        return getDataTable(list);
    }

    /**
     * 导出药房信息注册列表
     */
    @RequiresPermissions("system:yfxx:export")
    @Log(title = "药房信息注册", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(GxzyfYfxx gxzyfYfxx)
    {
        List<GxzyfYfxx> list = gxzyfYfxxService.selectGxzyfYfxxList(gxzyfYfxx);
        ExcelUtil<GxzyfYfxx> util = new ExcelUtil<GxzyfYfxx>(GxzyfYfxx.class);
        return util.exportExcel(list, "药房信息注册数据");
    }

    /**
     * 新增药房信息注册
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存药房信息注册
     */
    @RequiresPermissions("system:yfxx:add")
    @Log(title = "药房信息注册", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(GxzyfYfxx gxzyfYfxx)
    {
        return toAjax(gxzyfYfxxService.insertGxzyfYfxx(gxzyfYfxx));
    }

    /**
     * 修改药房信息注册
     */
    @RequiresPermissions("system:yfxx:edit")
    @GetMapping("/edit/{药房ID}")
    public String edit(@PathVariable("药房ID") String 药房ID, ModelMap mmap)
    {
        GxzyfYfxx gxzyfYfxx = gxzyfYfxxService.selectGxzyfYfxxBy药房ID(药房ID);
        mmap.put("gxzyfYfxx", gxzyfYfxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存药房信息注册
     */
    @RequiresPermissions("system:yfxx:edit")
    @Log(title = "药房信息注册", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(GxzyfYfxx gxzyfYfxx)
    {
        return toAjax(gxzyfYfxxService.updateGxzyfYfxx(gxzyfYfxx));
    }

    /**
     * 删除药房信息注册
     */
    @RequiresPermissions("system:yfxx:remove")
    @Log(title = "药房信息注册", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(gxzyfYfxxService.deleteGxzyfYfxxBy药房IDs(ids));
    }
}
